<?php
/**
 * Created by PhpStorm.
 * User: liujun
 * Date: 2018/6/24
 * Time: 下午11:08
 */

namespace PddWechat\Models\Index\Service;


use Dai\Framework\Base\BaseException;
use PddWechat\Models\User\Data\UserData;

class Index
{
    /**
     * @param $basePageInfo
     * @return \PddWechat\Models\User\DataObject\UserDo
     * @throws BaseException
     */
    public function execute($basePageInfo)
    {
        /** @var BaseSessionInfo $sessionData */
        $sessionData = $basePageInfo->sessionInfo;

        $userData = new UserData();
        $user = $userData->getUserByOpenId($sessionData->openId);
        if( $user == null) {
            throw new BaseException(BaseException::INTER_ERROR);
        }
        return $user;
    }
}